package com.yonyou.pmclouds.workflow.config;

import com.yonyou.pmclouds.workflow.service.ProcessVariableProcessor;
import com.yonyou.pmclouds.workflow.service.rmiitf.IProcessVariableExtendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class ProcessVariableExtendConfiguration implements BeanPostProcessor {


    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

        if (bean instanceof IProcessVariableExtendService) {
            ProcessVariableProcessor.addExtendService(((IProcessVariableExtendService) bean).getBillType(),
                    (IProcessVariableExtendService) bean);
        }

        return bean;
    }
}
